package com.lcy.eb.config;

import com.lcy.eb.mapper.EbProductCategoryMapper;
import com.lcy.eb.model.EbProductCategory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.ServletContext;
import java.util.List;

@Component
public class InitContext implements CommandLineRunner {

    @Resource
    private EbProductCategoryMapper ebProductCategoryMapper;
    @Resource
    private ServletContext application;
    @Override
    public void run(String... args) throws Exception {
        List<EbProductCategory> bigs = ebProductCategoryMapper.getBigCategory();
        List<EbProductCategory> smalls = ebProductCategoryMapper.getSmallCategory();
        application.setAttribute("bigs",bigs);
        application.setAttribute("smalls",smalls);

    }
}
